package com.erqi.dao.impl;

import com.erqi.dao.plcDao;
import com.erqi.mapper.master.QrandplcMapper;
import com.erqi.pojo.Qrandplc;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author king
 * @Date 2020/6/5 9:52
 * @Version 1.0
 */
@Service
public class plcDaoImpl implements plcDao {

    @Autowired
    QrandplcMapper qrandplcMapper;



    @Override
    public Qrandplc QueryPlcById(Integer id) {
        return qrandplcMapper.selectByPrimaryKey(id);
    }

    @Override
    public Integer selectByQrandplc(Qrandplc qrandplc) {
        return qrandplcMapper.selectByQrandplc(qrandplc);
    }

    @Override
    public int insertSelective(Qrandplc qrandplc) {
        return qrandplcMapper.insertSelective(qrandplc);
    }

    @Override
    public Integer selectByTypeAndCode(String type,String QRcode) {
        return qrandplcMapper.selectByTypeAndCode(type,QRcode);
    }

    /**
     * 11.12  修改为以第一次为准
     * 如果没有数据返回0 如果有数据返回1
     * @param type
     * @param code
     * @return
     */
    @Override
    public int checkPLCData_mySql(String type, String code) {
        List<Qrandplc> select = qrandplcMapper.select(type, code, "入库成功");
        if (select.size()<=0){
            return 0;
        }else{
            return 1;
        }
    }
}
